function Task_Data(data, tableid) {
	var buffer = new StringBuffer();
	$(data).each(function(i,info){
		try{
		info.Context=decodeURI(info.Context);
		}catch(e){}
		buffer.append('<div class="sharelist border-bottom" tableid="'+tableid+'" id="'+info.ID+'" userid="'+info.UserID+'" username="'+info.RealName+'" identity="'+info.Identity+'" state="'+info.State+'">');
		buffer.append('<div class="atitle">');
		buffer.append('<div class="aimg"><img src="'+info.HeadImg+'"/></div>');
		buffer.append('<div class="aname">'+info.RealName+'<font class="'+(info.State<=3?"reds":"greens")+'">'+info.StateText+'</font></div>');
		buffer.append('<div class="adate">'+info.CreateTime+'  &nbsp;&nbsp;&nbsp;&nbsp; 来自&nbsp;'+info.Version+'</div>');
		buffer.append('<div class="atag">任务</div>');
		buffer.append('</div>');
		if(info.ToUsers!="")
		{
			buffer.append('<div class="asendrange">抄送给：<font>'+info.ToUsers+'</font></div>');
		}
		buffer.append('<div class="aexeuser">该任务由 <font class="lightblue">'+info.ExecuteUserName+'</font> 执行，需在<font class="lightblue"> '+info.FinishDate.ToTime()+' </font>之前完成</div>');
		buffer.append('<div class="aimg">'); 
		$(info.Imgs).each(function(k,img)
		{
		var right=k%3==2?0:5;
		buffer.append('<figure class="asquare" style="width:'+(swidth-30)/3+'px; heigth:'+(swidth-30)/3+'px; margin-right:'+right+'px; float:left; display:block;" itemscope itemtype="http://schema.org/ImageObject"><a src="'+img.Img1000+'" itemprop="contentUrl" data-size="'+img.Width+'x'+img.Height+'"><img src="' + img.Img200 + '" width="'+(swidth-30)/3+'" height="'+(swidth-30)/3+'" itemprop="thumbnail" alt="Image description"/></a></figure>');
		});
		buffer.append('</div>');
		if(info.Files.length>0)
		{
		buffer.append('<div class="afile">');
		$.each(info.Files,function(i,info)
		{
					buffer.append('<div class="file_list">');
						buffer.append('<div class="file_icon"><img src="img/'+GetICON(info.Path)+'"/></div>');
						buffer.append('<div class="file_info">');
							buffer.append('<div class="file_name">' + info.Name + '</div>');
							buffer.append('<div class="file_size">' + GetSize(info.Size) + '</div>');  
						buffer.append('</div>'); 
						buffer.append('<div class="file_download"><a href="javascript:void(0)" onclick=DownLoad(this,"'+info.Path+'")></a></div>');
					buffer.append('</div>');
		});
		buffer.append('</div>');
		}
		buffer.append('<div class="acontent"><span>' + info.Context + '</span><div id="detail">'+info.Context.DHtml().Cut()+'</div></div>');
		if(info.Address!=""){
		buffer.append('<div class="aposition"><div class="icon"><img src="img/position2.png" height="22"/></div><div class="address">'+info.Address+'</div></div>');
		}
		buffer.append('<div class="atool">');
		if(info.UserID==userid){
		buffer.append('<div class="delete"><img src="img/delete.png" height="12"/></div>');
		}
		buffer.append('<div class="reply" text="回复"><img src="img/replyes.png" height="12"/></div></div>');
		if(info.ReplyList.length>0)
		{
			buffer.append('<div class="replylist">');
			$(info.ReplyList).each(function(i,reply){
				try{
				reply.Context=decodeURI(reply.Context);
				}catch(e){}
				if(reply.ParentID==0)
				{
					buffer.append('<div class="replyline" id="'+reply.ID+'" userid="'+reply.UserID+'" tableid="'+tableid+'" username="'+reply.UserName+'" sid="'+info.ID+'" parentid="'+reply.ParentID+'" state="'+reply.State+'"><font>'+reply.UserName+'：</font>'+reply.Context+'</div>');
				}else{
					buffer.append('<div class="replyline" id="'+reply.ID+'" userid="'+reply.UserID+'" tableid="'+tableid+'" username="'+reply.UserName+'" sid="'+info.ID+'" parentid="'+reply.ParentID+'" state="'+reply.State+'"><font>'+reply.UserName+'</font>回复<font>'+reply.ToUserName+'：</font>'+reply.Context+'</div>');
				}
			});
			buffer.append('</div>');
		}
		buffer.append('</div>');
	});
	return buffer.toString();
};


function Task_State(o) {
    $(o).parent().parent().parent().find("label").removeClass("greens");
    $(o).parent().next().addClass("greens");
    if($(o).val()=="4") 
    {
    	if($("#comment").length==0)
    	{
	    	var html = '<div id="comment" class="comment"><div class="score"><div><input id="five" name="score" type="radio" value="5" onclick="Select_Score(this)"></div><label for="five">5分</label></div><div class="score"><div><input id="four" name="score" type="radio" value="4" onclick="Select_Score(this)"></div><label for="four">4分</label></div><div class="score"><div><input id="three" name="score" type="radio" value="3" checked="checked" onclick="Select_Score(this)"></div><label for="three" class="greens">3分</label></div><div class="score"><div><input id="two" name="score" type="radio" value="2" onclick="Select_Score(this)"></div><label for="two">2分</label></div><div class="score"><div><input id="one" name="score" type="radio" value="1" onclick="Select_Score(this)"></div><label for="one">1分</label></div></div>';
	    	$(html).insertBefore(".mbutton");
    	}
    }else{
    	if($("#comment").length>0)
    	{
    		$("#comment").remove();
    	}
    }
};

function Init_Task(){
	get("divmsgname").addEventListener("tap",function(){
		OpenOAScreen(Task_Search_Code(),function(){
			Init_Task_Search();
		},function(){Data_Search(3)});
	});
	
};

function Task_Search_Code(){
	var buffer = new StringBuffer();
	buffer.append('<div class="searchtab"><div class="tab select" val="out">我发出的</div><div class="tab" val="in">我收到的</div></div>');
	buffer.append('<div class="searchline" style="margin-top:10px;"><div class="names">选择同事</div><div class="option"><input id="users_search" class="users" show="1" touserid="" todepartid="" tocomid="" type="text" placeholder="点击选择" readonly="readonly" value=""/></div></div>');
	buffer.append('<div class="searchline"><div class="names">任务状态</div><div class="option"><select id="state_search"><option value="">全部</option><option value="0">未完成</option><option value="4">已完成</option><option value="2">已取消</option></select></div></div>');
	buffer.append('<div class="searchline"><div class="names">发布时间</div><div class="option"><input id="begindate_search" type="text" class="date" placeholder="开始时间" readonly="readonly"/><input id="enddate_search" type="text" class="date" placeholder="结束时间" readonly="readonly"/></div></div>');
	return buffer.toString();
};

function Init_Task_Search(){
	mui(".searchtab").on("tap",".tab",function(){
		if($(this).attr("val")=="out")
		{
			$(this).css("border-right","1px solid #e3e2e2").siblings().css("border-left","0px");
		}else
		{
			$(this).css("border-left","1px solid #e3e2e2").siblings().css("border-right","0px");
		}
		$(this).addClass("select").siblings().removeClass("select");
		Data_Search(3);
	});
	mui(".option").on("tap",".date",function(){
		obj=this;
			var t=new Date();
			if($(this).val()!="")
			{
				var year_month_day=$(this).val().split("-");
				t.setFullYear(year_month_day[0]);
				t.setMonth(year_month_day[1]-1);
				t.setDate(year_month_day[2]);
			}
			plus.nativeUI.pickDate( function(e){
				var d=e.date;
				$(obj).val((d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate()).ToDate());
			},function(e){
				console.log( "未选择日期："+e.message );
			},{date:t});
	});
	get("users_search").addEventListener("tap",function(){
        	obj10=$(this);
			OpenWindow(3,"选择员工","确定",function(){
					var str1="",str2="",str3="",headimg="";
					touserid="";todepartid="";tocomid="";
	      			var count=0;
	      			mui.each(mui("#userlist input"),function(i,info){
	      				if(info.checked)
	      				{
	      					count++;
	      					touserid += info.value+",";
	      					str1 += info.getAttribute("val")+",";
	      				}
	      			});
	      			if(touserid.TrimEnd(",").split(",").length>1)
					{
						plus.nativeUI.toast("请选择1个员工");
						return;
					}
					if(str1=="")
	      			{
	      				obj10.val("").attr("touserid","");
	      			}else
	      			{
	      				
	      				obj10.val(str1.substring(0,str1.length-1)).attr("touserid",touserid.substring(0,touserid.length-1));
	      			}
	      			CloseWindow();
			});
			
			$("#contentlist3").html(CheckMate_Data());
			data = {};
			data.act = "DepartAndUser_Data";
			data.userid=userid;
			data.comid=comid;
			data.source=source;
			data.sign=GetSign(data.act);
			
			mui.getJSON(admin_domain, data, function(json) {
				Bind_CheckMate(json.data.user,json.data.depart);
				Init_CheckMate();
			});
			if($(this).attr("show")=="1")
	      	{
	      		$(".selectbar").hide();
	      	}else
	      	{
				$(".selectbar").show();  				
	      	}
	    });

};